package ioperation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-19
 * Time: 20:30
 */
public class FindOperation implements IOperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("查找图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要查找的书名");
        String name = scanner.nextLine();
        int currentSize = booklist.getUseSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBooks()[i];
            if(book.getName().equals(name)){
                System.out.println("找到了这本书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书");
    }
}
